from django.conf.urls import url
from rest_framework.routers import DefaultRouter

from meiduo_admin.views import users, specs, statistical, images, skus, orders, permissions, group, admin

from rest_framework_jwt.views import obtain_jwt_token

urlpatterns = [
    url('^authorizations/$', obtain_jwt_token),
    url(r'^statistical/total_count/$', statistical.UserCountView.as_view()),
    url(r'^statistical/day_increment/$', statistical.UserDayCountView.as_view()),
    url(r'^statistical/day_active/$', statistical.UserActiveCountView.as_view()),
    url(r'^statistical/day_orders/$', statistical.UserOrderCountView.as_view()),
    url(r'^statistical/month_increment/$', statistical.UserMonthCountView.as_view()),
    url(r'^statistical/goods_day_views/$', statistical.GoodsDayView.as_view()),
    # -----用户管理路由-----
    url(r'^users/$', users.UserView.as_view()),

    # ------------规格路由表-----------
    url(r'^goods/simple/$', specs.SpecsView.as_view({'get': 'simple'})),
    # ---------新增图片------
    url(r'^skus/simple/$', images.ImagesView.as_view({'get': 'simple'})),
    # ------------sku路由————————————
    url(r'^goods/(?P<pk>\d+)/specs/$', skus.SKUView.as_view({'get': 'specs'})),
    # ---------权限路由---------
    url(r'^permission/content_types/$', permissions.PermissionsView.as_view({'get': 'content_type'})),
    # --------权限组获取权限列表----------
    url(r'^permission/simple/$', group.GroupView.as_view({'get': 'simple'})),
    # 权限分组
    url(r'^permission/groups/simple/$', admin.AdminView.as_view({'get': 'simple'})),

]
# ------规格表------
router = DefaultRouter()
router.register('goods/specs', specs.SpecsView, base_name='specs')
urlpatterns += router.urls

# -------图片表路由------
router = DefaultRouter()
router.register('skus/images', images.ImagesView, base_name='images')
urlpatterns += router.urls

# --------sku路由--------
router = DefaultRouter()
router.register('skus', skus.SKUView, base_name='skus')
urlpatterns += router.urls

# 'skus', skus.SKUView, base_name='skus'

# --------订单路由--------
router = DefaultRouter()
router.register('orders', orders.OrderView, base_name='orders')
urlpatterns += router.urls

# --------权限路由--------
router = DefaultRouter()
router.register('permission/perms', permissions.PermissionsView, base_name='perms')
urlpatterns += router.urls

# --------分组路由--------
# http://127.0.0.1:8000/meiduo_admin/permission/groups/simple/
# http://127.0.0.1:8000/meiduo_admin/permission/groups/?page=1&pagesize=10
router = DefaultRouter()
router.register('permission/groups', group.GroupView, base_name='groups')
urlpatterns += router.urls

# --------管理员路由--------
router = DefaultRouter()
router.register('permission/admins', admin.AdminView, base_name='admin')
print('================================================')
print(router.urls)
print('================================================')
urlpatterns += router.urls

'''
/meiduo_admin/permission/admins/20/
[<RegexURLPattern admin-list ^permission/admins/$>,
 <RegexURLPattern admin-list ^permission/admins\.(?P<format>[a-z0-9]+)/?$>,
 <RegexURLPattern admin-detail ^permission/admins/(?P<pk>[^/.]+)/$>,
 <RegexURLPattern admin-detail ^permission/admins/(?P<pk>[^/.]+)\.(?P<format>[a-z0-9]+)/?$>,
 <RegexURLPattern api-root ^$>,
 <RegexURLPattern api-root ^\.(?P<format>[a-z0-9]+)/?$>]
'''